<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>添加编辑积分商品</title>
  <link href="__PUBLIC__/admin/css/xc.min.css" rel="stylesheet" type="text/css" />
  <link href="__PUBLIC__/admin/css/xc.admin.css" rel="stylesheet" type="text/css" />
  <link href="__PUBLIC__/lib/iconfont/iconfont.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.min.js"></script>
  <script type="text/javascript" src="__PUBLIC__/admin/js/xc.js"></script>
  <script type="text/javascript" src="__PUBLIC__/admin/js/xc.admin.js"></script>
  <script type="text/javascript" src="__PUBLIC__/admin/js/common-1.0.js"></script>
  <script type="text/javascript" src="__PUBLIC__/lib/layer/layer.js"></script>
  <script>
    $(function(){
      $(".tabCon .tabxuan:not(:first)").hide();
      $(".tabList .clearfix li").click(function(){
        $(".tabList .clearfix li").eq($(this).index()).addClass("cur").siblings().removeClass('cur');
        $(".tabxuan").hide().eq($(this).index()).show();
      })
    })
  </script>
  <style>
    .tabList li.cur{ border-top:1px solid #C40001; color:#C40001; font-weight:bold; background:url(__PUBLIC__/admin/images/daosan.png) no-repeat center top; background-color:#fff}
    #tab{ width:100%}
    #tab .tabList ul{border:1px solid #E6E6E6; margin:0; background-color:#F8F8F8}
    #tab .tabList ul li,#tab1 .tabList1 ul li {float:left; padding:0 20px;text-align:center;position:relative;cursor:pointer; height:50px; line-height:50px; border-right:1px solid #E6E6E6}
    #tab .tabList ul li span,#tab1 .tabList1 ul li span{ font-size:12px; margin-left:3px}
    #tab .tabCon{width:963px;}
    #tab .tabList li.cur{ border-top:1px solid #C40001; color:#C40001; font-weight:bold; background:url(__PUBLIC__/admin/images/daosan.png) no-repeat center top; background-color:#fff}
  </style>
</head>

<body>
<nav class="breadcrumb">
  <i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 商品管理 <span class="c-gray en">&gt;</span> 添加/编辑积分商品
  <a class="btn btn-success radius r mr-20 btn-shua" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="pd-20">
  <form action="" method="post" class="form form-horizontal" id="myform">
    <div id="tab-system" class="HuiTab">
      <div id="tab">
        <div class="tabList">
          <ul class="clearfix">
            <li class="cur">基本信息</li>
            <li>商品相册</li>
            <li>商品详情</li>
          </ul>
        </div>
      </div>
      <div class="tabCon">
        <div class="cur tabxuan">
          <div class="mt-20">
            <div class="row cl">
              <label class="form-label col-2"><span class="c-red">*</span>商品名称：</label>
              <div class="formControls col-9">
                <input type="text" class="input-text" placeholder="请输入商品名称" id="name" name="dg_name" value="{$list.dg_name}">
              </div>
            </div>
            <!--<div class="row cl">-->
            <!--&lt;!&ndash;<label class="form-label col-2"><span class="c-red">*</span>商品品牌：</label>-->
            <!--<div class="formControls col-3"> <span class="select-box" style="width:100%">-->
            <!--<select class="select" name="dg_brid" id="brid">-->
            <!--<option value="">请选择商品品牌</option>-->
            <!--<foreach name="brlist" item="vo" > -->
            <!--<option value="{$vo['br_id']}" <if condition="($vo['br_id'] eq $list[dg_brid])">selected</if> >{$vo['br_name']}</option>-->
            <!--</foreach>-->
            <!--</select>-->
            <!--</span>-->
            <!--</div>&ndash;&gt;-->
            <!--<label class="form-label col-2"><span class="c-red">*</span>商品分类：</label>-->
            <!--<div class="formControls col-3"> <span class="select-box" style="width:100%">-->
            <!--<select class="select" name="cat_id" id="cat_id">-->
            <!--<option value="">请选择商品分类</option>-->
            <!--<foreach name="calist" item="cvo"> -->
            <!--<option value="{$cvo['ca_id']}" <if condition="($cvo['ca_id'] eq $list[dg_caid])">selected</if> >{$cvo.level|treeEmpty}{$cvo['ca_name']}</option>-->
            <!--</foreach>-->
            <!--</select>-->
            <!--</span>-->
            <!--</div>-->
            <!--</div>-->
            <div class="row cl">
            <label class="form-label col-2"><span class="c-red">*</span>建议零售价：</label>
            <div class="formControls col-3">
            <input type="text" class="input-text" placeholder="请输入建议零售价" id="money" name="dg_money" value="{$list.dg_money}">
            </div>
            <label class="form-label col-2"><span class="c-red">*</span>批发价：</label>
            <div class="formControls col-3">
            <input type="text" class="input-text" placeholder="请输入本店批发价" id="price" name="dg_price" value="{$list.dg_price}">
            </div>
            </div>
            <div class="row cl">
<!--              <label class="form-label col-2"><span class="c-red">*</span>使用积分：</label>-->
<!--              <div class="formControls col-3">-->
<!--                <input type="text" class="input-text" placeholder="请输入使用积分数量" id="score" name="dg_score" value="{$list.dg_score|default='0'}">-->
<!--              </div>-->
              <!--<label class="form-label col-2"><span class="c-red">*</span>成本价：</label>-->
              <!--<div class="formControls col-3">-->
              <!--<input type="text" class="input-text" placeholder="请输入成本价" id="amount" name="dg_amount" value="{$list.dg_amount}">-->
              <!--</div>-->
            </div>
            <div class="row cl">
              <label class="form-label col-2"><span class="c-red">*</span>设置：</label>
              <div class="formControls col-9 skin-minimal">
                <div class="check-box">
                  <input type="checkbox"  id="c1" value="1" name="dg_sale" <if condition="$list.dg_sale eq 1">checked="checked"</if> />
                  <label for="c1">上架&nbsp;</label>
                </div>
<!--                <div class="check-box">-->
<!--                  <input type="checkbox" id="c3" value="1" name="dg_recom" <if condition="$list.dg_recom eq 1">checked="checked"</if> />-->
<!--                  <label for="c3">推荐&nbsp;</label>-->
<!--                </div>-->
<!--                <div class="check-box">-->
<!--                  <input type="checkbox" id="c4"  value="1" name="dg_new" <if condition="$list.dg_new eq 1">checked="checked"</if> />-->
<!--                  <label for="c4">新品&nbsp;</label>-->
<!--                </div>-->
<!--                <div class="check-box">-->
<!--                  <input type="checkbox" id="c5" value="1" name="dg_hot" <if condition="$list.dg_hot eq 1">checked="checked"</if>/>-->
<!--                  <label for="c5">促销&nbsp;</label>-->
<!--                </div>-->
              </div>
            </div>
            <div class="row cl">
              <label class="form-label col-2"><span class="c-red">*</span>库存：</label>
              <div class="formControls col-2">
                <input type="text" class="input-text" placeholder="请输入库存数量" id="stock" name="dg_stock" value="{$list.dg_stock|default='1000'}">
              </div>
<!--              <label class="form-label col-1"><span class="c-red">*</span>商品销量：</label>-->
<!--              <div class="formControls col-2">-->
<!--                <input type="text" class="input-text" placeholder="商品销量" id="sum" name="dg_sum" value="{$list.dg_sum|default=$click}">-->
<!--              </div>-->
<!--              <label class="form-label col-1"><span class="c-red">*</span>商品货号：</label>-->
<!--              <div class="formControls col-2">-->
<!--                <input type="text" class="input-text" placeholder="请输入商品货号" id="sn" name="dg_sn" value="{$list.dg_sn}">-->
<!--              </div>-->
            </div>
<!--            <div class="row cl">-->
<!--              <label class="form-label col-2"><span class="c-red">*</span>重量：</label>-->
<!--              <div class="formControls col-2">-->
<!--                <input type="text" class="input-text" placeholder="请输入商品重量" id="weight" name="dg_weight" value="{$list.dg_weight|default='500'}" style="width:70%"> 克-->
<!--              </div>-->
<!--              <label class="form-label col-1"><span class="c-red">*</span>商品运费：</label>-->
<!--              <div class="formControls col-2">-->
<!--                <input type="text" class="input-text" placeholder="请输入运费类型" id="free" name="dg_free" value="{$list.dg_free|default='1'}" style="width:30%">(0不包邮 1包邮)-->
<!--              </div>-->
<!--            </div>-->
<!--            <div class="row cl">-->
<!--              <label class="form-label col-2"><span class="c-red">*</span>商品关键词：</label>-->
<!--              <div class="formControls col-9">-->
<!--                <input type="text" class="input-text" placeholder="请输入商品的关键词" id="key" name="dg_key" value="{$list.dg_key}">-->
<!--              </div>-->
<!--            </div>-->
            <div class="row cl">
              <label class="form-label col-2"><span class="c-red">*</span>颜色分类：</label>
              <div class="formControls col-9">
                <input type="text" class="input-text" placeholder="用英文( , )号隔开" id="color" name="dg_color" value="{$list.dg_color}">
              </div>
            </div>
            <div class="row cl">
              <label class="form-label col-2"><span class="c-red">*</span>尺寸大小：</label>
              <div class="formControls col-9">
                <input type="text" class="input-text" placeholder="用英文( , )号隔开" id="size" name="dg_size" value="{$list.dg_size}">
              </div>
            </div>
            <div class="row cl">
              <label class="form-label col-2">商品简介：</label>
              <div class="formControls col-9">
                <textarea name="dg_con"  cols="" rows="" class="textarea" placeholder="请输入商品简介" dragonfly="true" onKeyUp="textarealength(this,100)">{$list.dg_con}</textarea>
                <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
              </div>
              <div class="col-3"> </div>
            </div>
          </div>
        </div>
      </div>
      <div class="tabCon">
        <div class="tabxuan">
          <div class="row cl">
            <label class="form-label col-2"><span class="c-red">*</span>商品缩略图：</label>
            <div class="formControls col-4"> <span class="btn-upload form-group">
            <input class="input-text upload-url" type="text" id="thumbImgUrl" name="thumbImgUrl" readonly style="width:250px" value="{$list.dg_thumb}" placeholder="请上传图像文件" />
            <a href="javascript:;" class="a-upload" onchange="uploadImage('myfile','dgods','thumb');"><input type="file" name="myfile" id="myfile" alt="上传文件">点击上传文件</a>
            </span><br/><font color="#f00">*请上传宽度800X高度800像素图片</font>
            </div>
            <div class="formControls col-2">
              <img id="thumbImg" src="__UPLOAD__/{$list.dg_thumb|default='img/no_image.jpg'}" style="width:100px; height:100px; float: left">
            </div>
          </div>
          <div class="row cl">
            <label class="form-label col-2"><span class="c-red">*</span>相册图集：</label>
            <div class="formControls col-8">
              <button type="button" class="layui-btn layui-btn-primary pull-left" id="slide-pc" style="float:left">选择多图</button>
              <div class="formControls l" style="color:#f00; padding:0.5rem">注：上传图片不大于2M（点击图片删除）</div>
              <div class="pic-more l">
                <ul class="pic-more-upload-list" id="slide-pc-priview">
                  <volist name="imgs" id="vo">
                    <li class="item_img">
                      <div class="operate"><i class="toleft layui-icon"></i><i class="toright layui-icon"></i><i  class="close layui-icon"></i></div>
                      <img src="/Public/Uploads/{$vo.im_url}" class="img" onClick="delimg(this,{$vo.im_id})" ><input type="hidden" name="pc_src[]" value="{$vo.im_url}" />
                    </li>
                  </volist>
                </ul>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="tabCon">
        <div class="tabxuan">
          <div class="row cl">
            <label class="form-label col-1"><span class="c-red">*</span>商品详情：</label>
            <div class="formControls col-10">
              <script id="weditor" name="dg_body" type="text/plain" style="width:100%;height:400px;">{$list.dg_body|htmlspecialchars_decode}</script>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="row cl">
      <div class="col-9 col-offset-3">
        <input type="hidden" name="id" value="{$list.dg_id}" />
        <input class="btn btn-primary radius" type="button" onClick="checkSubmit()" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
        <button class="btn btn-default radius" type="button" onClick="layer_close();"><i class='Hui-iconfont'>&#xe66b;</i> 取消</button>
      </div>
    </div>
  </form>
</div>
<!-- 文本编辑器 -->
<script type="text/javascript" src="__PUBLIC__/lib/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" src="__PUBLIC__/lib/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
  //加载文本编辑器插件
  $(function(){
    var ue = UE.getEditor('weditor');
  });
</script>
<!-- 文本编辑器-->
<script type="text/javascript">
  //按回车件触发提交
  document.onkeydown=function(event){
    var e = event || window.event || arguments.callee.caller.arguments[0];
    if(e && e.keyCode==13){ // enter 键
      checkSubmit();
    }
  };
  //提交数据
  function checkSubmit(){
    var name   = $.trim($('#name').val());
//	var cat1   = $.trim($('#cat_id').val());
//	var price  = $.trim($('#price').val());
//	var market = $.trim($('#market').val());
//	var amount = $.trim($('#amount').val());
    var bimgurl= $.trim($('#thumbImgUrl').val());
    var store  = $.trim($('#stock').val());
    var weight = $.trim($('#weight').val());
    var free   = $.trim($('#free').val());
    var key    = $.trim($('#key').val());
    if(name == ''){
      layer.msg('商品名称不能为空', {icon: 2});
      return false;
    }
//  if(cat1 == ''){
//		layer.msg('商品一级分类必选', {icon: 2});
//		return false;
//	}if(price == ''){
//		layer.msg('本店批发价不能为空!', {icon: 2});
//		return false;
//	}if(market == ''){
//		layer.msg('最低零售价不能为空!', {icon: 2});
//		return false;
//	}if(amount == ''){
//		layer.msg('成本价不能为空!', {icon: 2});
//		return false;
//	}
    if(store == ''){
      layer.msg('库存不能为空!', {icon: 2});
      return false;
    }if(bimgurl == ''){
      layer.msg('商品缩略图不能为空!', {icon: 2});
      return false;
    }
    $.ajax({
      type : 'post',
      url : '__MODULE__/Goods/dailiAddEdit',
      data : $("#myform").serialize(),
      dataType : 'json',
      success : function(res){
        if(res.status == 1){
          layer.msg(res.msg,{icon:1,time:2000},function(){
            // 先获取窗口索引，才能关闭窗口
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
          });
          parent.call_back_fun('success');
        }else{
          layer.msg(res.msg, {icon: 2});
        }
      },
      error : function(XMLHttpRequest, textStatus, errorThrown) {
        layer.alert('网络失败，请刷新页面后重试',{icon:2});
      }
    })
  }
</script>
<!-- 商品相册 -->
<link href="__PUBLIC__/lib/layui/css/layui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/lib/layui/layui.all.js"></script>
<style type="text/css">
  .layui-upload-img { width: 90px; height: 90px; margin: 0; }
  .pic-more { width:100%; left; margin: 10px 0px 0px 0px;}
  .pic-more li { width:90px; float: left; margin-right: 5px;}
  .pic-more li .layui-input { display: initial; }
  .pic-more li a { position: absolute; top: 0; display: block; }
  .pic-more li a i { font-size: 24px; background-color: #008800; }
  #slide-pc-priview .item_img img{ width: 90px; height: 90px;}
  #slide-pc-priview li{position: relative;}
  #slide-pc-priview li .operate{ color: #fff; display: none;}
  #slide-pc-priview li .toleft{ position: absolute;top: 40px; left: 1px; cursor:pointer;}
  #slide-pc-priview li .toright{ position: absolute;top: 40px; right: 1px;cursor:pointer;}
  #slide-pc-priview li .close{position: absolute;top: 5px; right: 5px;cursor:pointer;}
  #slide-pc-priview li:hover .operate{ display: block;}
</style>
<script type="text/javascript">
  layui.use('upload', function(){
    var $ = layui.jquery;
    var upload = layui.upload;
    upload.render({
      elem: '#slide-pc',
      url: "{:U('Hoteladmin/Uploader/uploading')}",
      size: 2048,
      exts: 'jpg|png|jpeg',
      multiple: true,
      before: function(obj) {
        layer.msg('图片上传中...', {icon: 16,shade: 0.01,time: 0})
      },
      done: function(res) {
        layer.close(layer.msg());//关闭上传提示窗口
        if(res.status == 0) {
          return layer.msg(res.message);
        }
        //$('#slide-pc-priview').append('<input type="hidden" name="pc_src[]" value="' + res.filepath + '" />');
        var html = '<li class="item_img">';
        html+= '<div class="operate"><i class="toleft layui-icon"></i><i class="toright layui-icon"></i></div>';
        html+= '<img src="/Public/Uploads/' + res.filepath + '" class="img" ><input type="hidden" name="pc_src[]" value="' + res.filepath + '" />';
        html+= '</li>';
        $('#slide-pc-priview').append(html);
      }
    });
  });
  //点击多图上传的X,删除当前的图片
  //$("body").on("click",".close",function(){
  //    $(this).closest("li").remove();
  //});

  //删除缩略图
  function delimg(obj,id){
    $.ajax({
      type : 'post',
      url : '__MODULE__/Goods/de',
      data : {id:id},
      dataType : 'json',
      success : function(res){
      }
    })
    $(obj).parent("li").remove();
  }

  //多图上传点击<>左右移动图片
  $("body").on("click",".pic-more ul li .toleft",function(){
    var li_index=$(this).closest("li").index();
    if(li_index>=1){
      $(this).closest("li").insertBefore($(this).closest("ul").find("li").eq(Number(li_index)-1));
    }
  });
  $("body").on("click",".pic-more ul li .toright",function(){
    var li_index=$(this).closest("li").index();
    $(this).closest("li").insertAfter($(this).closest("ul").find("li").eq(Number(li_index)+1));
  });
</script>
<!-- 商品相册 -->
<!-- 单选 复选框 -->
<link href="__PUBLIC__/lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/lib/icheck/jquery.icheck.min.js"></script>
<script type="text/javascript">
  $(function(){
    $('.skin-minimal input').iCheck({
      checkboxClass: 'icheckbox-blue',
      radioClass: 'iradio-blue',
      increaseArea: '20%'
    });
  });
</script>
<!-- 单选 复选框 -->
</body>
</html>